<template>
	<view class="">
		<home-pages ref="home-pages" v-show="jnPostrion == 'home-pages'" />
		<classification-pages ref="classificationPages" v-show="jnPostrion == 'classificationPages'" />
		<shopping-cart-pages ref="shoppingCartPages" v-show="jnPostrion == 'shoppingCartPages'" />
		<my-pages ref="my-pages" v-show="jnPostrion == 'my-pages'" />
		<!-- 底部按钮 -->
		<tabbar ref="tabbar" @click="handleTabbarClick"></tabbar>
	</view>
</template>

<script>
	import tabbar from "./components/tabbar.vue";
	import homePages from "./home/index.vue";
	import classificationPages from "./classification/index.vue";
	import myPages from "./my/index.vue";
	import shoppingCartPages from "./shoppingCart/index.vue";
	import {
		realmName
	} from "@/http";
	export default {
		components: {
			tabbar,
			homePages,
			classificationPages,
			myPages,
			shoppingCartPages
		},
		data() {
			return {
				jnPostrion: "",
				tabbarData: ["home-pages",
					"classificationPages",
					"shoppingCartPages",
					"my-pages"
				],
				classificationLeftList: [],
				shoppingCartList: []
			}
		},
		onReachBottom() {
			if(this.jnPostrion == 'home-pages') this.$refs['home-pages'].handlePageNumData();
		},
		onShow() {
			if(this.jnPostrion){
				this.$refs[this.jnPostrion].init();
			}
		},
		onLoad({index}) {
			index = Number(index) || 0;
			this.handleTabbarClick(index);
		},
		methods: {
			handleTabbarClick(e) {
				this.$nextTick(()=>{
					this.jnPostrion = this.tabbarData[e];
					this.$refs['tabbar'].value = e;	
					this.$refs[this.jnPostrion].init();
				})
			}
		}
	}
</script>
<style lang="scss" scoped>
</style>
